import { Quill } from 'vue-quill-editor'

// 源码中是import直接倒入，这里要用Quill.import引入
const BlockEmbed = Quill.import('blots/block/embed')

class Video extends BlockEmbed {
  static create (value) {
    let node = super.create()
    node.setAttribute('src', value.url)
    node.setAttribute('controls', 'controls')
    node.setAttribute('data-index', value.dataIndex)
    node.setAttribute('data-size', value.dataSize)
    node.setAttribute('webkit-playsinline', true)
    node.setAttribute('playsinline', true)
    node.setAttribute('x5-playsinline', true)
    return node;
  }
 
  static value (node) {
    return {
      url: node.getAttribute('src'),
      dataIndex: node.getAttribute('data-index'),
      dataSize: node.getAttribute('data-size')
    };
  }
  
}

Video.blotName = 'video'
Video.className = 'ql-video'
Video.tagName = 'video'

export default Video